#ifndef CMAINWINDOW_H
#define CMAINWINDOW_H

#include "cframelesswidget.h"
#include "ctitlebar.h"
#include "vlckits.h"
#include "cbottomctrlbar.h"
#include "cplaylist.h"
#include "cvideowidget.h"
#include "cprogressbar.h"

#include <windows.h>

#include <QSlider>
#include <QLabel>
#include <QListWidget>
#include <QDateTime>

#include <vlc/vlc.h>


class CMainWindow
: public CFramelessWidget
{
    Q_OBJECT
public:
    explicit CMainWindow(QWidget * parent= nullptr);
    void titleDoubleClickEvent();

private slots:
    void closeSlot();//与子对象CTitleBar::sigClose信号绑定

private:
    void initUI();
    void initfileMenuItems(QMenu*fileMenuItems);
    void initmenu(QMenu *menu);

    void keyPressEvent(QKeyEvent* event) override;
    void videoWidgetMoveEvent();

    void mouseMoveEvent(QMouseEvent* event) override;

    void hideWidget();
    void showWidget();


    void timerEvent(QTimerEvent* event) override;

    //void mousePressEvent(QMouseEvent* event) override;
    //void contextMenuEvent(QContextMenuEvent *event) override;
    void playIdx(int idx);


    //void mouseDoubleClickEvent(QMouseEvent *event) override;




private slots:
    void on_btnOpen_clicked();
    void play_pause();
    void on_btnStop_clicked();
    void fullScreen();

    void setCurPlayTime(const qint64 &curMs);
    void setTotalTime(const qint64 &tatalMs);
    void setTimeSliderValue(int position);

    void onPlaylistItemClicked(QListWidgetItem *item);
    void list();

    void setCurrIdx(int idx){   _currIdx = idx; }
    void playPre();
    void playNext();
signals:


private:
    CTitleBar * _ptitleBar = nullptr;//主窗口中包含标题栏

    CProgressBar *_hSlider = nullptr;

    CBottomCtrlBar *_cbcb = nullptr;

    CPlayButtonGroupWidget* _playbtn = nullptr;

    //VLC
    VLCKits *_vlcKits = nullptr;

    bool _isplay = false;

    CPlayList *_playlistwidget = nullptr;

    QString _currentFile;

    QPushButton *_btMenuCenter = nullptr;

    bool _isRunning = false;

    int _timerId = 0;//定时器id

    QDateTime lastMouseMoveTime;

    unordered_set<QString> *_list = nullptr;

    //QMenu * menu;

    int _currIdx = -1;

    CVideoWidget *_cVideoWidget;

    bool _isStopTotal = false;
    bool _isStopCurr = false;
};

#endif // CMAINWINDOW_H
